import 'package:flutter/material.dart';
import 'package:flutter_yfree/YFree.dart';

class MyScrollView extends StatelessWidget {
  MyScrollView({
    required this.children,
    this.padding = EdgeInsets.zero,
    this.controller,
    this.physics,
    super.key,
  });

  final List<Widget> children;
  EdgeInsetsGeometry padding = EdgeInsets.zero;
  final ScrollController? controller;
  final ScrollPhysics? physics;

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      physics: physics,
      padding: padding,
      controller: controller,
      primary: false,
      shrinkWrap: true,
      itemCount: children.length,
      itemBuilder: (context, index) => children[index],
    );
  }
}

BoxDecoration MyBoxDecoration({
  Gradient? gradient,
  Color? color,
  List<BoxShadow>? boxShadow,
  BoxBorder? border,
  DecorationImage? image,
  BorderRadiusGeometry? borderRadius,
  BlendMode? backgroundBlendMode,
  BoxShape shape = BoxShape.rectangle,
}) {
  if (gradient != null && color == null) {
    color = gradient.colors.firstOrNull ?? Colors.transparent;
  }
  return BoxDecoration(
    color: yIsWeb ? color : (gradient == null ? color : null),
    gradient: yIsWeb ? null : gradient,
    boxShadow: yIsWeb ? null : boxShadow,
    border: border,
    image: image,
    borderRadius: borderRadius,
    backgroundBlendMode: backgroundBlendMode,
    shape: shape,
  );
}

class MyFontWeight {
  MyFontWeight._();

  ///常用3个
  static const FontWeight Regular = FontWeight.w400;
  static const FontWeight Medium = FontWeight.w500;
  static const FontWeight Semibold = FontWeight.w600;

  // Add more custom font weights as needed
  static const FontWeight ExtraLight = FontWeight.w200;
  static const FontWeight Light = FontWeight.w300;
  static const FontWeight Bold = FontWeight.w700;
  static const FontWeight Black = FontWeight.w900;
}
